package com.ruoyi.store.service.impl;

import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.stage.domain.StuStage;
import com.ruoyi.store.domain.StuQuestionStore;
import com.ruoyi.store.mapper.StuQuestionMapper;
import com.ruoyi.store.mapper.StuQuestionStoreMapper;
import com.ruoyi.store.service.IStuQuestionStoreService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class StuQuestionStoreImpl implements IStuQuestionStoreService {

    @Resource
    private StuQuestionStoreMapper stuQuestionStoreMapper;
    @Resource
    private StuQuestionMapper stuQuestionMapper;

    @Override
    public List<StuQuestionStore> selectStuQuestionStoreList(StuQuestionStore stuQuestionStore) {
        return stuQuestionStoreMapper.selectStuQuestionStoreList(stuQuestionStore);
    }

    @Override
    public StuQuestionStore selectStoreById(Long storeId) {
        return stuQuestionStoreMapper.selectStoreById(storeId);
    }

    @Override
    public int insertStore(StuQuestionStore stuQuestionStore) {
        return stuQuestionStoreMapper.insertStore(stuQuestionStore);
    }

    @Override
    public String checkStoreNameUnique(StuQuestionStore stuQuestionStore) {
        Long StoreId = StringUtils.isNull(stuQuestionStore.getStoreId()) ? -1L : stuQuestionStore.getStoreId();
        StuQuestionStore info = stuQuestionStoreMapper.checkStoreNameUnique(stuQuestionStore.getStoreName());
        if (StringUtils.isNotNull(info) && info.getStoreId().longValue() != StoreId.longValue())
        {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }

    @Override
    public int updateStore(StuQuestionStore stuQuestionStore) {
        return stuQuestionStoreMapper.updateStore(stuQuestionStore);
    }

    @Override
    public int deleteStoreByIds(Long[] storeIds) {
        return  stuQuestionStoreMapper.deleteStoreByIds(storeIds);
    }

    @Override
    public List<StuQuestionStore> selectAllStores() {
        return stuQuestionStoreMapper.selectAllStores();
    }

    @Override
    public List<Long> selectStuStoresListByQuesId(Long quesId) {
        return stuQuestionStoreMapper.selectStuStoresListByQuesId(quesId);
    }

    @Override
    public int refreshStat(String storeId) {
        return stuQuestionStoreMapper.refreshStat(storeId);
    }

    @Override
    public Long selectStoreCounts(Long storeId) {

        return stuQuestionStoreMapper.selectStoreCounts(storeId);
    }
}
